package com.party.common.core.domain.entity;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.*;

import com.baomidou.mybatisplus.annotation.TableField;
import com.party.common.annotation.Excel;
import com.party.common.annotation.Excels;
import com.party.common.core.domain.BaseEntity;
import com.party.common.core.domain.entity.SysDept;
import com.party.common.core.domain.entity.SysRole;
import com.party.common.xss.Xss;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.party.common.annotation.Excel;
import com.party.common.annotation.Excel.ColumnType;
import com.party.common.annotation.Excel.Type;
import com.party.common.annotation.Excels;


/**
 * 用户对象 sys_user
 *
 * @author ruoyi
 */
public class SysUser extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @Excel(name = "用户序号", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号")
    private Long userId;

    /**
     * 编号
     */
    @Excel(name = "编号")
    private String code;

    /**
     * 部门ID
     */
    @Excel(name = "部门编号", type = Type.IMPORT)
    private Long deptId;

    /**
     * 用户账号
     */
    @Excel(name = "登录名称")
    private String userName;

    /**
     * 用户昵称
     */
    @Excel(name = "用户名称")
    private String nickName;

    /**
     * 用户邮箱
     */
    @Excel(name = "用户邮箱")
    private String email;

    /**
     * 手机号码
     */
    @Excel(name = "手机号码", cellType = ColumnType.TEXT)
    private String phonenumber;

    /**
     * 用户性别
     */
    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    private String sex;

    /**
     * 用户头像
     */
    private String avatar;

    /**
     * 密码
     */
    private String password;

    /**
     * 帐号状态（0正常 1停用）
     */
    @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
    private String status;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    private String delFlag;
    /**
     * 用户类型（00系统用户）
     */
    private String userType;

    /**
     * 设备编码
     */
    private String sbCode;


    private long gl;
    /**
     * 我的余额
     */
    private BigDecimal amount;
    /**
     * 银行卡账号
     */
    private String payCode;
    /**
     * 银行开户行
     */
    private String payBank;
    /**
     * 邀请人手机号
     */
    private String invitedPhone;


    private String openId;

    private String address;

    /**
     * 最后登录IP
     */
    @Excel(name = "最后登录IP", type = Type.EXPORT)
    private String loginIp;

    /**
     * 最后登录时间
     */
    @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
    private Date loginDate;

    /**
     * 部门对象
     */
    @Excels({
            @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
            @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
    })
    private SysDept dept;

    /**
     * 角色对象
     */
    private List<SysRole> roles;

    /**
     * 角色组
     */
    private Long[] roleIds;

    /**
     * 岗位组
     */
    private Long[] postIds;

    /**
     * 角色ID
     */
    private Long roleId;
    /**
     * 负责人
     */
    private String principal;
    /**
     * 身份证号
     */
    private String idCard;
    /**
     * 门店简介
     */
    private String unitRemark;

    /**
     * 是否是超级俱乐部添加账号：0是  1否
     */
    private String isClubAdd;
    /**
     * 超级俱乐部能够开通的合伙人账户数量,默认为10
     */
    private Integer clubUnitNum = 10;

    @TableField(exist = false)
    private String clubUserId;
    /**
     * "交付中心id"
     */
    @TableField(exist = false)
    private String payUserId;
    /**
     * "用户名"
     */
    @TableField(exist = false)
    private String roleName;
    /**
     * "用户名"
     */
    @TableField(exist = false)
    private Integer learnNum = 0;
    /**
     * 教练id
     */
    @TableField(exist = false)
    private String coachId;
    /**
     * "角色类型": 0:教练 1：交付小组组长  2：学管师
     */
    @TableField(exist = false)
    private String roleType;

    public SysUser() {

    }

    @Override
    public String toString() {
        return "SysUser{" +
                "userId=" + userId +
                ", code='" + code + '\'' +
                ", deptId=" + deptId +
                ", userName='" + userName + '\'' +
                ", nickName='" + nickName + '\'' +
                ", email='" + email + '\'' +
                ", phonenumber='" + phonenumber + '\'' +
                ", sex='" + sex + '\'' +
                ", avatar='" + avatar + '\'' +
                ", password='" + password + '\'' +
                ", status='" + status + '\'' +
                ", delFlag='" + delFlag + '\'' +
                ", userType='" + userType + '\'' +
                ", sbCode='" + sbCode + '\'' +
                ", gl=" + gl +
                ", amount=" + amount +
                ", payCode='" + payCode + '\'' +
                ", payBank='" + payBank + '\'' +
                ", invitedPhone='" + invitedPhone + '\'' +
                ", openId='" + openId + '\'' +
                ", address='" + address + '\'' +
                ", loginIp='" + loginIp + '\'' +
                ", loginDate=" + loginDate +
                ", dept=" + dept +
                ", roles=" + roles +
                ", roleIds=" + Arrays.toString(roleIds) +
                ", postIds=" + Arrays.toString(postIds) +
                ", roleId=" + roleId +
                ", principal='" + principal + '\'' +
                ", idCard='" + idCard + '\'' +
                ", unitRemark='" + unitRemark + '\'' +
                ", isClubAdd='" + isClubAdd + '\'' +
                ", clubUnitNum=" + clubUnitNum +
                ", clubUserId='" + clubUserId + '\'' +
                ", payUserId='" + payUserId + '\'' +
                ", roleName='" + roleName + '\'' +
                ", learnNum=" + learnNum +
                ", coachId='" + coachId + '\'' +
                ", roleType='" + roleType + '\'' +
                '}';
    }

    public String getRoleType() {
        return roleType;
    }

    public void setRoleType(String roleType) {
        this.roleType = roleType;
    }

    public String getCoachId() {
        return coachId;
    }

    public void setCoachId(String coachId) {
        this.coachId = coachId;
    }

    public Integer getLearnNum() {
        return learnNum;
    }

    public void setLearnNum(Integer learnNum) {
        this.learnNum = learnNum;
    }

    public String getIsClubAdd() {
        return isClubAdd;
    }

    public void setIsClubAdd(String isClubAdd) {
        this.isClubAdd = isClubAdd;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public SysUser(Long userId) {
        this.userId = userId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public boolean isAdmin() {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId) {
        return userId != null && 1L == userId;
    }

    public Integer getClubUnitNum() {
        return clubUnitNum;
    }

    public void setClubUnitNum(Integer clubUnitNum) {
        this.clubUnitNum = clubUnitNum;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    @Xss(message = "用户昵称不能包含脚本字符")
    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Xss(message = "用户账号不能包含脚本字符")
    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getPhonenumber() {
        return phonenumber;
    }

    public void setPhonenumber(String phonenumber) {
        this.phonenumber = phonenumber;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public SysDept getDept() {
        return dept;
    }

    public void setDept(SysDept dept) {
        this.dept = dept;
    }

    public List<SysRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }

    public Long[] getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(Long[] roleIds) {
        this.roleIds = roleIds;
    }

    public Long[] getPostIds() {
        return postIds;
    }

    public void setPostIds(Long[] postIds) {
        this.postIds = postIds;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public long getGl() {
        return gl;
    }

    public void setGl(long gl) {
        this.gl = gl;
    }

    public String getSbCode() {
        return sbCode;
    }

    public void setSbCode(String sbCode) {
        this.sbCode = sbCode;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public String getPayCode() {
        return payCode;
    }

    public void setPayCode(String payCode) {
        this.payCode = payCode;
    }

    public String getPayBank() {
        return payBank;
    }

    public void setPayBank(String payBank) {
        this.payBank = payBank;
    }

    public String getInvitedPhone() {
        return invitedPhone;
    }

    public void setInvitedPhone(String invitedPhone) {
        this.invitedPhone = invitedPhone;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getPrincipal() {
        return principal;
    }

    public void setPrincipal(String principal) {
        this.principal = principal;
    }

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    public String getUnitRemark() {
        return unitRemark;
    }

    public void setUnitRemark(String unitRemark) {
        this.unitRemark = unitRemark;
    }

    public String getClubUserId() {
        return clubUserId;
    }

    public void setClubUserId(String clubUserId) {
        this.clubUserId = clubUserId;
    }

    public String getPayUserId() {
        return payUserId;
    }

    public void setPayUserId(String payUserId) {
        this.payUserId = payUserId;
    }

}
